//
// Created by 86156 on 25-7-5.
//

#ifndef PID_DRIVER_H
#define PID_DRIVER_H
#include <stdint.h>
#include "tim.h"


typedef struct {
    float Kp;
    float Kd;
    float Ki;
    float Output_Max;
    float Iout_Max;

    float Err;
    float Err_last;
    float Err_sum;

    float Differ;
    float Ilimit;
    float Irang;
    float Integral;
    uint8_t Ilimit_flag;

    float POut;
    float IOut;
    float DOut;
    float totalOut;
} PID_t;


void PID_Init(PID_t *pid, float Kp, float Ki, float Kd, float MaxI, float MaxOut);
void PID_Position_Cal(PID_t *pid,float target,float real);
void PIDCaculation_Angle(PID_t *pid);
void PIDCaculation_Speed(PID_t *pid);
void PidParameter_Init(PID_t *PID_ROL_Angle,PID_t *PID_YAW_Angle,PID_t *PID_Depth,PID_t *PID_PIT_Angle,PID_t *PID_View, PID_t *PID_ROL_Speed,  PID_t *PID_PIT_Speed, PID_t *PID_YAW_Speed);

#endif //PID_DRIVER_H
